package com.xjj.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjj.entity.Klass;
import com.xjj.entity.School;
import com.xjj.entity.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author sxy
 * @version 1.0
 * @date 2022/10/20 15:09
 */
@Mapper
public interface KlassMapper extends BaseMapper<Klass> {
    @Update("update xjj_klass set job_num=job_num+1 where id=#{id}")
    void addJobNumById(Klass klass);
    @Update("update xjj_klass set klass_verify = #{klassVerify} where id = #{id}")
    void updateVerifyById(@Param("klassVerify") String klassVerify, @Param("id") int id);
    @Update("update xjj_klass set job_num=#{jobNum} where id =#{id}")
    void subJobNumBuId(@Param("jobNum") int jobNum,@Param("id") int id);
    @Select("select * from xjj_klass where id=#{id}")
    Klass getKlassById(int id);

    @Select("SELECT r.* FROM xjj_klass r,xjj_klass_teacher ur,xjj_manager u WHERE u.id=ur.manager_id AND ur.klass_id = r.id AND u.id = #{id}")
    List<Klass> getKlassByManagerId(int id);

    @Select("select * from xjj_klass where name = #{name}")
    Klass getKlassByName(String name);

    @Select("select * from xjj_klass where master_id = #{id}")
    Klass getKlassByMasterId(int id);


}
